// copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
// see COPYRIGHT for reuse legalities
//


#import "RIBShadingRate.h"

@implementation RIBShadingRate

+ initialize { return [RIBShadingRate setVersion:1], self; }

- init
{
  [super init];
  shadingRate = 100.;

  return self;
}

- awake
{
  [super awake];

  return self;
}

- setShadingRate:(RtFloat)newShadingRate
{
   shadingRate = newShadingRate; 
   return self;
}

- (RtFloat)shadingRate { return shadingRate; }


- renderSelf:(WW3DCamera *)camera  startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
{
  RiShadingRate(shadingRate);
  return self;
}

- writeEve:(NXStream *)stream atTabLevel:(int)tab
{
   int  i;


   for (i = 0; i < tab; i++)
   {  NXPrintf(stream, "\t");
   }
   NXPrintf(stream, "ShadingRate %f;", shadingRate); 
   return self;
}

#define typeVector "f"
#define typeValues &shadingRate

- read:(NXTypedStream *)stream 
{
    int version;
    [super read:stream];

NX_DURING
    version = NXTypedStreamClassVersion(stream,"RIBShadingRate");
    if (version == 0) NXReadTypes(stream,"i",&version), version=1;
    if (version == 1)
    {  NXReadTypes(stream, typeVector, typeValues);
    } 
NX_HANDLER
   NXLogError("in read: %s, exception [%d] raised.\n", 
                 [[self class] name], NXLocalHandler.code);
   return nil;
NX_ENDHANDLER
    return self;
}

- write:(NXTypedStream *)stream 
{
    [super write:stream];

    NXWriteTypes(stream, typeVector, typeValues);

    return self;
}

@end
